package mainPackage;

import inputPackage.KeyResource;

import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import viewPackage.KaPow;
import viewPackage.menus.MainMenuPanel;

public class StartClass {

	/**
	 * @param args
	 */
	
	public static Resource resource;
	public static void main(String[] args) {
		resource = new Resource();
		new StartClass();

	}

	public StartClass(){

			try {
				UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
			} catch (ClassNotFoundException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} catch (InstantiationException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} catch (IllegalAccessException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} catch (UnsupportedLookAndFeelException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}

		
		KeyResource keys = new KeyResource();
		keys.readFromFile();
		
		KaPow kapow = new KaPow();
		
		GFrame gameFrame = new GFrame(keys, kapow);
		
		//This is the setup space for a fullscreen option.
		if ( resource.isFullScreen == true) {
			DisplayMode dm = new DisplayMode (resource.screenWidth,resource.screenHeight,32,60);
			GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
			GraphicsDevice gd = ge.getDefaultScreenDevice();
			gameFrame.setUndecorated(true);
			gameFrame.setResizable(false);
			gd.setFullScreenWindow(gameFrame);
			gd.setDisplayMode(dm);
		}
		
		//This is the setup space for a windowed option.
		else {
			gameFrame.setBounds(0, 0, resource.screenWidth,resource.screenHeight);
			gameFrame.setLocationByPlatform(true);
			gameFrame.setVisible(true);
			gameFrame.setResizable(false);
		}
		
		
		gameFrame.add(new MainMenuPanel(gameFrame));
		
		
		
	}
}
